package com.xjscrm.console.service.customer.operatePlan.impl;

import com.xjscrm.common.constant.ResponseMsg;
import com.xjscrm.common.entity.FaqReplyDevice;
import com.xjscrm.common.exception.BusinessException;
import com.xjscrm.common.result.ResponseCode;
import com.xjscrm.console.param.operatePlan.BatchFaqReplyDto;
import com.xjscrm.console.service.customer.operatePlan.FaqRepiyBatchService;
import com.xjscrm.console.service.customer.operatePlan.FaqReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class FaqRepiyBatchServiceImpl implements FaqRepiyBatchService {

    @Autowired
    private FaqReplyService faqReplyService;
    @Override
    public void batchdeleFaqReplyDevice(BatchFaqReplyDto batchFaqReplyDto) {
        if(batchFaqReplyDto.getIds()==null||batchFaqReplyDto.getIds().isEmpty()){
            throw new BusinessException(ResponseCode.BUSINESS_EXCEPTION, ResponseMsg.PARAMETER_ERROR);
        }

        for (Long id:batchFaqReplyDto.getIds()) {
            try {
                batchFaqReplyDto.setId(id);
                faqReplyService.deleFaqReplyDevice(batchFaqReplyDto);
            }catch (Exception e){
                e.printStackTrace();
            }
        }

    }

    @Override
    public void batchAddReplyDevice(BatchFaqReplyDto batchFaqReplyDto) {
        if(batchFaqReplyDto.getIds()==null||batchFaqReplyDto.getIds().isEmpty()){
            throw new BusinessException(ResponseCode.BUSINESS_EXCEPTION, ResponseMsg.PARAMETER_ERROR);
        }
        for (Long id:batchFaqReplyDto.getIds()) {
            try {
                batchFaqReplyDto.setId(id);
                faqReplyService.AddReplyDevice(batchFaqReplyDto);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
